#!/usr/bin/pyenv python
import urllib.request
import os
from drivers.android import devices
import time
import ssl

#解决证书问题
ssl._create_default_https_context = ssl._create_unverified_context
#下载最新App
apk_name="app_release.apk"
def download_apk():
	url = "https://app-release.360che.com/app-speed/android/latestVersion/{0}".format(apk_name)
	response = urllib.request.urlopen(url)
	apk = response.read()
	with open(apk_name, 'wb') as f:
		f.write(apk)

#安装最新App c3c25c35
def install_apk():
	for device_s in devices():
		install_command = "adb -s %s install -r %s" % (device_s, apk_name)
		os.system(install_command)

download_apk()
install_apk()

# ps:如果是首次安装需要在手机端同意"usb安装提示"，覆盖安装无需
